package one.stand.service.impl;

import one.stand.mapper.OfficialApplyMapper;
import one.stand.mapper.OfficialContactMapper;
import one.stand.mapper.OfficialFromMapper;
import one.stand.model.OfficialApplyModel;
import one.stand.model.OfficialContactModel;
import one.stand.model.OfficialFromModel;
import one.stand.model.ResultModel;
import one.stand.request.OfficialApplyRequest;
import one.stand.request.OfficialContactRequest;
import one.stand.request.OfficialFromRequest;
import one.stand.service.OfficialService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author: ZRH
 * @CreateDate: 2019/4/11 17:25
 */
@Service
public class OfficialServiceImpl implements OfficialService {

    @Autowired
    private OfficialApplyMapper officialApplyMapper;

    @Override
    public ResultModel saveOfficialApply(OfficialApplyRequest request) {
        if(request == null){
            return ResultModel.checkParamFail();
        }
        OfficialApplyModel model = new OfficialApplyModel();
        BeanUtils.copyProperties(request,model);
        officialApplyMapper.insertSelective(model);
        return ResultModel.success();
    }

    @Autowired
    OfficialContactMapper officialContactMapper;

    @Override
    public ResultModel saveOfficialContact(OfficialContactRequest request) {
        if(request == null){
            return ResultModel.checkParamFail();
        }
        OfficialContactModel model = new OfficialContactModel();
        BeanUtils.copyProperties(request,model);
        officialContactMapper.insertSelective(model);
        return ResultModel.success();
    }

    @Autowired
    OfficialFromMapper officialFromMapper;

    @Override
    public ResultModel saveOfficialFrom(OfficialFromRequest request) {
        if(request == null){
            return ResultModel.checkParamFail();
        }
        OfficialFromModel model = new OfficialFromModel();
        BeanUtils.copyProperties(request,model);
        officialFromMapper.insertSelective(model);
        return ResultModel.success();
    }
}
